package com.zyh.day03

object FunctionTest {
  def main(args: Array[String]): Unit = {
    val work1: (Int,Int) => Int = (a:Int,b:Int) => if(a>b) a else b
    val work2: Int => Long = (m: Int) => if(m==0) 1 else fact(m-1)*m
    println(work1(1, 2))
    println(work2(10))

    val f:Int=>Long = fact
    (a:Int,b:Int) => a+b
      val f1:(Int,Int)=>Int = (a:Int,b:Int)=>a+b
      val f2:(Int,Int)=>Int = _ + _
      //val addTwo:(Int,Int)=>Int = (x,y)=> sum(x,y)
      //val addTwo:(Int,Int)=>Int = sum(_,_)
      //val addTwo:(Int,Int)=>Int = sum _
      val addTwo:(Int,Int)=>Int = sum
  }
  def fact(m: Int): Long = if(m==0) 1 else fact(m-1)*m
  def f(m: Int): Long = {
    if(m>0) f(m-1)*m else 1
  }
  def sum(a:Int,b:Int) = a+b
}
object Test_{
  def main(args: Array[String]): Unit = {
    val f:(Int,Int)=>Int = (a:Int,b:Int)=>a+b
    val f1: (Int,Int)=>Int = _ + _
    println(f1(1, 2))

    //(a:Int,b:Int)=>a>b;
    val f2: (Int,Int)=>Boolean = _ > _
    println(f2(10, 20))

    //(a:Int) => a>0
    val f3: Int=>Boolean = _ > 0
    println(f3(10))
  }
}